const express = require('express');
const router = express.Router();
const transactionController = require('../controllers/transactionController');
const { authenticate, requireAdmin, checkUserAccess } = require('../middleware/auth');

// 创建交易（充值/消费）- 管理员操作
router.post('/', authenticate, requireAdmin, transactionController.createTransaction);

// 获取交易记录列表（管理员）
router.get('/', authenticate, requireAdmin, transactionController.getTransactions);

// 获取单条交易记录
router.get('/:id', authenticate, transactionController.getTransactionById);

// 获取用户交易记录
router.get('/user/:userId', authenticate, checkUserAccess, transactionController.getUserTransactions);

module.exports = router;
